<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>找出只出现一次的那两个元素。你可以按 任意顺序 返回答案。</title>
</head>

<body>
  <script>

    var res = [];
    var arr = function (array) {
      for (let i = 0; i < array.length; i++) {
        if (array.indexOf(array[i]) === array.lastIndexOf(array[i])) {
          res.push(array[i]);
        }
      }
      return res;
    }
    console.log(arr([1, 2, 4, 5, 1, 2, 3]));
  </script>
</body>

</html>